<?php


namespace app\common\model\mysql;


use think\Model;

class Goods extends BaseModel
{
    public function getNormalGoods($data)
    {
        $query = $this->where(['status' => 1]);
        if (isset($data['title'])) {
            $query->where('title', 'like', '%' . $data['title'] . '%');
        }

        return $query->paginate(10);
    }

    public function getRotationChart()
    {
        $field = "sku_id as id ,title , big_image as image";

        return $this->where(['is_index_recommend' => 1, 'status' => 1])->field($field)->limit(4)->select();
    }

    public function getNormalGoodsFindInsertCategoryId($cate_id, $field)
    {
        return $this->whereFindInSet('category_path_id', $cate_id)
            ->where(['status' => 1])
            ->field($field)->limit(10)
            ->select();
    }

    public function getCarouselImage($value)
    {
        if (!empty($value)) {
            return explode(',', $value);
        }

        return $value;
    }
}